import http from '@/http';
import { Column, Article, PaginatedResponse } from '@/types/content';

export const contentService = {
  // 栏目
  getColumns() {
    return http.get<PaginatedResponse<Column>>('/api/content/columns/');
  },
  createColumn(data: Partial<Column>) {
    return http.post('/api/content/columns/', data);
  },
  updateColumn(id: number, data: Partial<Column>) {
    return http.put(`/api/content/columns/${id}/`, data);
  },
  deleteColumn(id: number) {
    return http.delete(`/api/content/columns/${id}/`);
  },

  // 文章
  getArticles() {
    return http.get<PaginatedResponse<Article>>('/api/content/articles/');
  },
  createArticle(data: FormData) {
    return http.post('/api/content/articles/', data, {
      headers: { 'Content-Type': 'multipart/form-data' }
    });
  },
  updateArticle(id: number, data: FormData) {
    return http.put(`/api/content/articles/${id}/`, data, {
      headers: { 'Content-Type': 'multipart/form-data' }
    });
  },
  deleteArticle(id: number) {
    return http.delete(`/api/content/articles/${id}/`);
  },
}; 